//
//  RTJBorrowingCell.m
//  RuiTaiJinProject
//
//  Created by jayson on 2019/4/1.
//  Copyright © 2019年 leewei. All rights reserved.
//

#import "RTJBorrowingCell.h"

@implementation RTJBorrowingCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    [self backview:_bg_view viewOfcornerRadius:5];
    [self backview:_bg_view1 viewOfcornerRadius:5];
    _tipview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 0, 4)];
    _tipview.layer.cornerRadius = _view1.height/2;
    _tipview.layer.masksToBounds = YES;
    _tipview.backgroundColor = [UIColor yellowColor];
//    [self.view1 addSubview:_tipview];
}

-(void)setData:(NSDictionary *)data{
    
    if (_isReimbursement) {
        
        _title1.text = data[@"name"];
        NSString *next_repay_time_format = [NSString stringWithFormat:@"%@",data[@"next_repay_time_format"]];
        _time1.text =next_repay_time_format.length!=0 ? [NSString stringWithFormat:@"(%@)",next_repay_time_format] :@"";
        _type1.text = data[@"pay_status_format"];
        _money1.text = data[@"borrow_amount"];
        _rate1.text = [NSString stringWithFormat:@"%@%@",data[@"rate"],@"%"];
        _date1.text = data[@"repay_time"];
        
    }else{
        
        _title2.text = data[@"name"];
        _type2.text = data[@"pay_status_format"];
        _money2.text = data[@"borrow_amount"];
        _rate2.text = [NSString stringWithFormat:@"%@%@",data[@"rate"],@"%"];
        _date2.text = data[@"repay_time"];
        _lab2.text = [NSString stringWithFormat:@"%@%@",data[@"progress_point"],@"%"];
        NSString *w = [NSString stringWithFormat:@"%@",data[@"progress_point"]];
        
        if (screenW>375) {
            
            _view2W.constant = (_view1.width+screenW*85/375)*([w floatValue]/100);//xr

        }else{
            
            _view2W.constant = (_view1.width+screenW*55/375)*([w floatValue]/100);

        }
    }
}

-(void)setBorrowData:(NSDictionary *)borrowData{
    
    _money3.text = [NSString stringWithFormat:@"借款金额：%@元",borrowData[@"borrow_amount"]];
    _rate3.text = [NSString stringWithFormat:@"借款利率：%@%@",borrowData[@"rate"],@"%"];
    _time3.text = [NSString stringWithFormat:@"借款时间：%@",borrowData[@"create_time"]];
    _date3.text = [NSString stringWithFormat:@"借款期限：%@",borrowData[@"repay_time"]];
    _keyong.text = [NSString stringWithFormat:@"可用金额：%@元",borrowData[@"user_money"]];

}

-(void)setBorrowData1:(NSDictionary *)borrowData1{

    NSInteger status = [borrowData1[@"status"]integerValue];
    
    
    
    if (status == 2) {
        
        _img.hidden = YES;
        _lab4.hidden = YES;
        
    }else{
        
        _img.hidden = status == 1 ? NO : YES;
        _lab4.hidden =  status == 1 ? YES : NO;
        
        _numLab.textColor = status == 1 ? [UIColor colorForHex:@"#333333"] : [UIColor colorForHex:@"#999999"];
        _lab5.textColor = status == 1 ? [UIColor colorForHex:@"#333333"] : [UIColor colorForHex:@"#999999"];
        _money4.textColor = status == 1 ? [UIColor colorForHex:@"#FE623C"] : [UIColor colorForHex:@"#999999"];
        _lab6.textColor = status == 1 ? [UIColor colorForHex:@"#333333"] : [UIColor colorForHex:@"#999999"];
        _lab7.textColor = status == 1 ? [UIColor colorForHex:@"#333333"] : [UIColor colorForHex:@"#999999"];
        _lixi4.textColor = status == 1 ? [UIColor colorForHex:@"#FE623C"] : [UIColor colorForHex:@"#999999"];
    }
    
    _numLab.text = borrowData1[@"number"];
    _money4.text = [NSString stringWithFormat:@"%@元",borrowData1[@"repay_money"]];
    _lixi4.text = [NSString stringWithFormat:@"%@元",borrowData1[@"interest_money"]];

}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
-(void)backview:(UIView *)backview viewOfcornerRadius:(NSInteger)cornerRadius{
    
    backview.layer.cornerRadius = cornerRadius;
    backview.layer.shadowColor = [UIColor colorForHex:@"#dbc9cc"].CGColor;
    backview.layer.shadowOffset = CGSizeMake(-1, 1);
    backview.layer.shadowOpacity = 0.5;
    backview.layer.shadowRadius = 5;
    
}
@end
